package com.fancy.learncenter.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.fancy.learncenter.R;
import com.fancy.learncenter.common.Constant;
import com.fancy.learncenter.db.RecorderAudioDBManager;
import com.fancy.learncenter.ui.activity.base.BaseActivity;
import com.fancy.learncenter.ui.adapter.FragPagerAdapter;
import com.fancy.learncenter.ui.fragment.LocationAuidoFragment;
import com.fancy.learncenter.ui.fragment.OnlineAuidoFragment;
import com.fancy.learncenter.utils.LogUtil;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;


public class MyRecorderAudioActivity extends BaseActivity {


    @Bind(R.id.tab_layout)
    TabLayout tabLayout;
    @Bind(R.id.view_pager)
    ViewPager viewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_recorder_audio, Status.STATUS, "我的录音");
        ButterKnife.bind(this);
        initViewPager();
    }

    private void initViewPager() {
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(new OnlineAuidoFragment());
        fragments.add(new LocationAuidoFragment());

        List titles = new ArrayList();
        titles.add("已发布的录音");
        titles.add("本地录音");
        FragPagerAdapter mFragmentAdapteradapter =
                new FragPagerAdapter(getSupportFragmentManager(), fragments, titles);
        //给ViewPager设置适配器
        viewPager.setAdapter(mFragmentAdapteradapter);

        tabLayout.setTabMode(TabLayout.MODE_FIXED);
        //为TabLayout添加tab名称
        tabLayout.addTab(tabLayout.newTab());
        tabLayout.addTab(tabLayout.newTab());
        tabLayout.setupWithViewPager(viewPager);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        LogUtil.MyLog("onActivityResult", "=====onActivityResultonActivityResult====");
    }
}
